﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Graphics;

namespace Star_Wars
{
    class GoalManager
    {
        public Sprite goalSprite;
        public Vector2 location;
        private int height = 400;
        private int width = 700;
        public bool isAchieved = false;
        private int goalRadius = 30;
        private Random rand = new Random();
        public GoalManager(Texture2D texture, Rectangle initialFrame)
        {
            location = new Vector2(rand.Next(50, this.width), rand.Next(50, this.height));
            goalSprite = new Sprite(texture, location, new Vector2(0, 0), new Rectangle(0, 0, initialFrame.Width, initialFrame.Height));
            goalSprite.CollisionRadius = goalRadius;
        }
        private void Relocate()
        {
            goalSprite.Location = new Vector2(rand.Next(0, this.width), rand.Next(0, this.height));
        }
        public void Update(GameTime gameTime)
        {
            if (isAchieved)
            {
                Relocate();
                isAchieved = false;
            }
            goalSprite.Rotation += 0.01f;
            goalSprite.Update(gameTime);
        }
        public void Draw(SpriteBatch spriteBatch)
        {
            goalSprite.Draw(spriteBatch);
        }
    }
}
